import com.beans.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;


public class App {
    public static void main(String[] args) {
        //得到bean工厂
        //BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("Spring-config.xml"));
        //获取bean
        //User user = (User) beanFactory.getBean("user");
        //使用bean
        //user.siHai("孙苗苗");
        //得到Spring上下文对象
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("Spring-config.xml");
        //根据上下获取bean对象
        //User user = (User) applicationContext.getBean("user");
        //根据bean类型获取bean
        //User user = applicationContext.getBean(User.class);
        //根据bean名字和类型获取bean对象
        User user = applicationContext.getBean("user",User.class);
        //使用
        user.siHai("刘依凡");
    }
}